<!-- myRelease -->
<template>
  <div>
    <div class="myRelease">
      <div class="workContain">
        <div
          class="workCard"
          v-for="(item, index) in workArray"
          :key="index"
          divided
          @click="goDetails(item.id)"
        >
          <div class="work_details" divided>
            <div>{{ item.title }}</div>
            <div>{{ item.publisher.username }}</div>
            <div>{{ item.province }} {{ item.city }}</div>
            <div>{{ item.tags_string }}</div>
          </div>
        </div>
      </div>
    </div>
    <div class="page">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="workCurrentPage"
        :page-sizes="[10, 40, 100]"
        :page-size="workPageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="workTotalElement"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  computed: {
    ...mapGetters([
      "workCurrentPage",
      "workPageSize",
      "workTotalElement",
      "workArray",
    ]),
  },
  mounted() {
    this.jobsInit();
  },
  methods: {
    jobsInit() {
      this.$store
        .dispatch("work/lookMyWork")
        .then((data) => {
          console.log(data);
        })
        .catch((error) => {
          this.$message.error("信息初始化失败，请刷新页面重试");
        });
    },
    handleSizeChange(val) {
      this.$store.dispatch("work/setPageSize", val);
    },
    handleCurrentChange(val) {
      this.$store.dispatch("work/setCurrentPage", val);
    },
    goDetails(id) {
      this.$router.push("/work" + "?workId=" + id);
    },
  },
};
</script>

<style lang='scss' scoped>
</style>